package cn.tedu;

import java.io.*;

//OutputStream   抽象类
//测试字节流写出
public class Test3 {
    public static void main(String[] args) throws IOException {
        method();
        method2();

    }
    private static void method() throws IOException {
        OutputStream out=new FileOutputStream("F:\\ideaIO\\1.txt");
        OutputStream out2=new FileOutputStream(new File("F:\\ideaIO\\1.txt"));
        out.write(50);
        out.write(51);
        out.write(52);
        out.close();
        OutputStream out3=new FileOutputStream("F:\\ideaIO\\1.txt",true);//数据追加
        out3.write(90);
        out3.write(90);
        out3.write(90);
        //out3.close();可以不写
    }
    public static void method2() throws IOException {
        OutputStream out=new BufferedOutputStream(new FileOutputStream("F:\\ideaIO\\1.txt",true));
        out.write(90);
        out.write(90);
        out.write(90);
        //把写出流里的数据 刷到磁盘里的两种方式(1)(2) 必须写 二选一
        out.close();//(1)刷新+关闭    关闭此输出流并释放与此流有关的所有系统资源。
       // out.flush();(2)只刷新     刷新此输出流并强制写出所有缓冲的输出字节。
    }
}
